package domain;

import org.springframework.format.annotation.DateTimeFormat;
import utils.DateUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 产品信息
 *
 * @author Freedy
 * @date 2020-12-20
 */
public class Product implements Serializable {

    private static final long serialVersionUID = 1629926402792012177L;
    /**
     * 主键
     */
    private Integer id;

    /**
     * 产品编号
     */
    private String productNum;

    /**
     * 产品名称
     */
    private String productName;

    /**
     * 出发城市
     */
    private String cityName;

    /**
     * 出发时间
     */
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    private Date departureTime;
    private String departureTimeStr;

    /**
     * 产品价格
     */
    private String productPrice;

    /**
     * 产品描述
     */
    private String productDesc;

    /**
     * 状态(0关闭1开启)
     */
    private Integer productStatus;
    private String productStatusStr;

    @Override
    public String toString() {
        return "Product{" +
                "id='" + id + '\'' +
                ", productNum='" + productNum + '\'' +
                ", productName='" + productName + '\'' +
                ", cityName='" + cityName + '\'' +
                ", departureTime=" + departureTime +
                ", departureTimeStr='" + departureTimeStr + '\'' +
                ", productPrice='" + productPrice + '\'' +
                ", productDesc='" + productDesc + '\'' +
                ", productStatus=" + productStatus +
                ", productStatusStr='" + productStatusStr + '\'' +
                '}';
    }

    public String getDepartureTimeStr() throws Exception {
        if (departureTime!=null){
            departureTimeStr= DateUtils.date2string(departureTime,"yyyy-MM-dd HH:mm:ss");
        }
        return departureTimeStr;
    }

    public void setDepartureTimeStr(String departureTimeStr) {
        this.departureTimeStr = departureTimeStr;
    }

    public String getProductStatusStr() {
       if (productStatus!=null){
           if (productStatus==0){
               productStatusStr="关闭";
           }
           if (productStatus==1){
               productStatusStr="开启";
           }
       }
       return productStatusStr;
    }

    public void setProductStatusStr(String productStatusStr) {
        this.productStatusStr = productStatusStr;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }


    public String getProductNum() {
        return productNum;
    }

    public void setProductNum(String productNum) {
        this.productNum = productNum;
    }


    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }


    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }


    public Date getDepartureTime() {
        return departureTime;
    }

    public void setDepartureTime(Date departureTime) {
        this.departureTime = departureTime;
    }


    public String getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(String productPrice) {
        this.productPrice = productPrice;
    }


    public String getProductDesc() {
        return productDesc;
    }

    public void setProductDesc(String productDesc) {
        this.productDesc = productDesc;
    }


    public Integer getProductStatus() {
        return productStatus;
    }

    public void setProductStatus(Integer productStatus) {
        this.productStatus = productStatus;
    }

}
